import { combineReducers } from 'redux'
function reducer_login(state = {}, action) {

    switch (action.type) {
        case 'LoginSuccess':
            console.log("LoginSuccess");
            console.log(action.payload);
            return { login_info: action.payload };
        default:
            return state;
    }
}
//发现模块-交互
function reducer_discovery_interact(state = {}, action) {
    switch (action.type) {
        //交互-学生端-获取题目id和题目号SendSubjectID
        case 'InteractionPushSubjectId':
            console.log("InteractionPushSubjectId", action.payload);
            return { InteractionPushSubjectId: action.payload };
        //学生端单击交互获取最新题目和上课号
        case 'StudentGetPushSubjectId':
            console.log("StudentGetPushSubjectId", action.payload);
            return { StudentGetPushSubjectId: action.payload };
        //推送题目号
        case 'PushSendSubjectID':
            console.log("PushSendSubjectID", action.payload);
            return { SendSubjectID: action.payload };
        case 'GetInteractionCourseId':
            console.log("GetInteractionCourseId", action.payload);
            return { interaction_course: action.payload };
        case 'GetSubject':
            console.log("GetSubject", action.payload);
            return { subject: action.payload };
        default:
            return state;
    }
}
//课程-交互-教师端-获取InteractionCourseId和OnlineClassID
function reducer_courseInteract_Get_InteractionCourseId_OnlineClassID(state = {}, action) {
    switch (action.type) {
        case 'Get_InteractionCourseId_OnlineClassID':
            console.log("Get_InteractionCourseId_OnlineClassID", action.payload);
            return { InteractionCourseId_OnlineClassID: action.payload };
        default:
            return state;
    }
}
//发现-交互-交互课程id和mooc课程id
function reducer_discovery_interact_class(state = {}, action) {
    switch (action.type) {
        case 'GetInteractionCourseId':
            console.log("GetInteractionCourseId", action.payload);
            return { interaction_course: action.payload };
        default:
            return state;
    }
}
// //课程-交互-交互课程id和mooc课程id
// function reducer_discovery_interact_class_course(state = {}, action) {
//     switch (action.type) {
//         case 'GetInteractionCourseId_course':
//             console.log("GetInteractionCourseId_course", action.payload);
//             return { interaction_course_course: action.payload };
//         default:
//             return state;
//     }
// }


//发现-交互-教师端获取交互题目资源-题目信息
function reducer_discovery_interact_question(state = {}, action) {
    switch (action.type) {
        case 'GetSubject':
            console.log("GetSubject", action.payload);
            return { subject: action.payload };
        default:
            return state;
    }
}
//课程-交互-教师端获取交互题目资源-题目信息
function reducer_discovery_interact_question_course(state = {}, action) {
    switch (action.type) {
        case 'GetSubject_course':
            console.log("GetSubject_course", action.payload);
            return { subject_course: action.payload };
        default:
            return state;
    }
}
//课程-交互-教师端-获取InteractionCourseId和OnlineClassID
function reducer_courseInteract_teacherGet_SendSubjectID(state = {}, action) {
    switch (action.type) {
        case 'PushSendSubjectID':
            console.log("PushSendSubjectID", action.payload);
            return { SendSubjectID: action.payload };
        default:
            return state;
    }
}
//学生端：历史答题，题目详情之题目id
function reducer_discovery_interact_object_student(state = {}, action) {
    switch (action.type) {
        case 'GetObjectIdAnswerListStu':
            console.log("GetObjectIdAnswerListStu", action.payload);
            return { ObjectAnswerListStu: action.payload };
        default:
            return state;
    }
}
// //交互题目推送
// function reducer_interactionpush_subjectid(state = {}, action) {
//     switch (action.type) {
//         //交互推送题目id
//         case 'InteractionPushSubjectId':
//             console.log("InteractionPushSubjectId", action.payload);
//             return { InteractionPushSubjectId:action.payload };
//         default:
//             return state;
//     }
// }
function reducer_course_module(state = {}, action) {
    switch (action.type) {
        case 'GetCourseIdSuccess':
            return { course_info: action.payload };
        case 'GetChapterIdSuccess':
            return { chapter_info: action.payload };
        case 'GetDepartmentInfo':
            return { department_info: action.payload };
        case 'DepartmentCourseIdSuccess':
            return { morecourseid: action.payload };
        case 'GetResourceUrl':
            return { resourseURL: action.payload };
        default:
            return state;
    }
}

function reducer_course_info(state = {}, action) {
    switch (action.type) {
        case 'GetCourseIdSuccess':
            return { course_info: action.payload };
        default:
            return state;
    }
}

function reducer_message_info(state = {}, action) {
    switch (action.type) {
        case 'SchoolMessageList':
            return { school_info: action.payload };
        case 'CourseMessageList':
            return { course_info: action.payload };
        default:
            return state;
    }
}

export default combineReducers({
    login: reducer_login,
    //发现
    intercation: reducer_discovery_interact,
    intercation_class: reducer_discovery_interact_class,
    intercation_question: reducer_discovery_interact_question,
    intercation_question_before: reducer_discovery_interact_object_student,
    //发现

    course: reducer_course_module,
    course_info: reducer_course_info,
    message: reducer_message_info,
    //课程交互
    intercation_question_course: reducer_discovery_interact_question_course,
    courseInteract_Get_InteractionCourseId_OnlineClassID: reducer_courseInteract_Get_InteractionCourseId_OnlineClassID,
    courseInteract_teacherGet_SendSubjectID: reducer_courseInteract_teacherGet_SendSubjectID,

})